package com.google.code.p.restrpc.client.serial;

import java.util.HashMap;
import java.util.Map;

import com.google.code.p.restrpc.TransferFormat;

/**
 * 
 * @author dz
 *
 */
public class FormatSerializationProviderManager {
    
    public static Map<TransferFormat, FormatSerializationProvider> repo = new HashMap<TransferFormat, FormatSerializationProvider>();
    
    static {
        register(new JsonSerializationProvider());
    }
    
    public static boolean supports(TransferFormat format) {
        return repo.containsKey(format);
    }
    
    public static FormatSerializationProvider getFormatSerializationProvider(TransferFormat format) {
        return repo.get(format);
    }
    
    public static void register(FormatSerializationProvider provider) {
        repo.put(provider.getSupportedFormat(), provider);
    }
    
    public static void unregister(FormatSerializationProvider provider) {
        repo.remove(provider.getSupportedFormat());
    }
    
}
